<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="区县" prop="qy">
        <el-select v-model="queryParams.qy" placeholder="请选择" clearable size="small">
          <el-option
            v-for="dict in qyList"
            :key="dict.v"
            :label="dict.n"
            :value="dict.v"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="学校" prop="zxdm">
        <el-select v-model="queryParams.zxdm" placeholder="请选择" clearable filterable size="small">
          <el-option
            v-for="dict in zxmcList"
            :key="dict.zxdm"
            :label="dict.zxmc"
            :value="dict.zxdm"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="开始时间" prop="startTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.startTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="endTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.endTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['business:progress:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table id="export" v-loading="loading" :data="resultList">
      <el-table-column label="区县代码" align="center" prop="qy" fixed/>
      <el-table-column label="中学名称" align="center" prop="zxmc" fixed/>
      <el-table-column label="考试计划" align="center" prop="plagtime" fixed/>
      <el-table-column label="总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="total"/>
        <el-table-column label="未考完" align="center" prop="wknum"/>
        <el-table-column label="已考完" align="center" prop="yknum"/>
      </el-table-column>
      <el-table-column label="长跑总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[0].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[0].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[0].yknum"/>
      </el-table-column>
      <el-table-column label="跳远总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[1].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[1].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[1].yknum"/>
      </el-table-column>
      <el-table-column label="篮球总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[2].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[2].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[2].yknum"/>
      </el-table-column>
      <el-table-column label="排球总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[3].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[3].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[3].yknum"/>
      </el-table-column>
      <el-table-column label="跳绳总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[4].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[4].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[4].yknum"/>
      </el-table-column>
      <el-table-column label="引体向上总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[5].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[5].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[5].yknum"/>
      </el-table-column>
      <el-table-column label="仰卧起坐总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[6].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[6].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[6].yknum"/>
      </el-table-column>
      <el-table-column label="游泳总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[7].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[7].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[7].yknum"/>
      </el-table-column>
      <el-table-column label="足球总体进度" align="center">
        <el-table-column label="总人数" align="center" prop="projectList[8].total"/>
        <el-table-column label="未考完" align="center" prop="projectList[8].wknum"/>
        <el-table-column label="已考完" align="center" prop="projectList[8].yknum"/>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
  import { getSuZhouQuYu, listSchool } from '@/api/business/school/school'
  import { exportExcel, list } from '@/api/business/progress/examProgress'

  export default {
  name: 'Result',
  dicts: [],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 考生考试项目汇总成绩表格数据
      resultList: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        qy: null,
        zxdm: null,
        startTime: null,
        endTime: null
      },
      zxmcList: [],
      //区域列表
      qyList: [],
      form: {}
    }
  },
  created() {
    this.loading = false
    this.getList()
      listSchool().then(response => {
      this.zxmcList = response.rows
    })
    getSuZhouQuYu().then(response => {
      this.qyList = response.data
    })
  },
  methods: {
    getList() {
      this.loading = true
      list(this.queryParams).then(response => {
        this.resultList = response.rows
        this.total = response.total;
        this.loading = false;
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$modal.confirm('是否确认导出？').then(() => {
        this.exportLoading = true
        return exportExcel(queryParams)
      }).then(response => {
        this.$download.name(response.msg)
        this.exportLoading = false
      }).catch(() => {
      })
    }
  }
}
</script>
